<?php

session_start();
require_once("function.php");
require_once("Manager.php");
//require_once("logInController.php");


class employeeRecordController
{
	function isValidEmployeeData($employeeNo)
	{
		if(empty($employeeNo))
			return false;
		return true;
	}	
	function sendEmployeeForm($managerNo,$employeeNo)
	{
		if(self::isValidEmployeeData($employeeNo))
		{
			$user = new Manager;
			$user->addEmployee($managerNo,$employeeNo);
			$_SESSION['stat'] = "add_employee_success";
			$_SESSION['msg'] = "Employee successfully added!";
		}
		else
		{
			$_SESSION['stat'] = "add_employee_error";
			$_SESSION['msg'] = "Invalid data, failed to add employee";
		}
	}
}

$addEmployee = new employeeRecordController;

$employeeNumber = $_POST['employeeNumber'];
$managerNumber = $_POST['managerNumber'];

$addEmployee->sendEmployeeForm($managerNumber, $employeeNumber);
header("Location: managerpage.php");
?>
